<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>symlink</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_009_276">&nbsp;</a>NAME</h4><blockquote>
symlink - make symbolic link to a file
</blockquote><h4><a name = "tag_000_009_277">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="unistd.h.html">unistd.h</a>&gt;

int symlink(const char *<i>path1</i>, const char *<i>path2</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_009_278">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>symlink()</i>
function creates a symbolic link.  Its name is the pathname pointed to by
<i>path2</i>, which must be a pathname that does not name an existing file
or symbolic link.  The contents of the symbolic link are the string pointed to
by <i>path1</i>.
</blockquote><h4><a name = "tag_000_009_279">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>symlink()</i>
returns 0.  Otherwise, it returns -1 and sets <i>errno</i> to indicate the
error.
</blockquote><h4><a name = "tag_000_009_280">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>symlink()</i>
function will fail if:
<dl compact>

<dt>[EACCES]<dd>
Write permission is denied in the directory where the symbolic link is being
created, or search permission is denied for a component of the path prefix of
<i>path2</i>.

<dt>[EEXIST]<dd>
The <i>path2</i> argument names an existing file or symbolic link.

<dt>[EIO]<dd>
An I/O error occurs while reading from or writing to the file system.

<dt>[ELOOP]<dd>
Too many symbolic links were encountered in resolving <i>path2</i>.

<dt>[ENAMETOOLONG]<dd>

The length of the <i>path2</i> argument exceeds {PATH_MAX}, or a pathname
component is longer than {NAME_MAX}.

<dt>[ENOENT]<dd>
A component of <i>path2</i> does not name an existing file
or <i>path2</i> is an empty string.

<dt>[ENOSPC]<dd>
The directory in which the entry for the new symbolic link is being placed
cannot be extended because no space is left on the file system containing the
directory, or the new symbolic link cannot be created because no space is left
on the file system which will contain the link, or the file system is out of
file-allocation resources.

<dt>[ENOTDIR]<dd>
A component of the path prefix of <i>path2</i> is not a directory.

<dt>[EROFS]<dd>
The new symbolic link would reside on a read-only file system.

</dl>
<p>
The
<i>symlink()</i>
function may fail if:
<dl compact>

<dt>[ENAMETOOLONG]<dd>

Pathname resolution of a symbolic link produced an intermediate result whose
length exceeds {PATH_MAX}.

</dl>
</blockquote><h4><a name = "tag_000_009_281">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_282">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
Like a hard link,
a symbolic link allows a file to have multiple logical names.  The presence of
a hard link guarantees the existence of a file, even after the original name
has been removed.  A symbolic link provides no such assurance; in fact, the
file named by the <i>path1</i> argument need not exist when the link is
created.  A symbolic link can cross file system boundaries.
<p>
Normal permission checks are made on each component of the
symbolic link pathname during its resolution.
<br>
</blockquote><h4><a name = "tag_000_009_283">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_284">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="lchown.html">lchown()</a></i>,
<i><a href="link.html">link()</a></i>,
<i><a href="lstat.html">lstat()</a></i>,
<i><a href="open.html">open()</a></i>,
<i><a href="readlink.html">readlink()</a></i>,
<i><a href="unistd.h.html">&lt;unistd.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
